package communicationMessages;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import logger.LoggerWriter;
import database.DB;
//userNane
//subForum
//return list of users that can be banned from this subForum
public class GetListOfOptionalBannededMessage extends Message{
	@Override
	public String getAnswer() {
		String answer = null;
		String []arr = this.content.split(delimiter);
		LoggerWriter logger = LoggerWriter.getLoggerWriter();
		if (arr.length != 2)
		{
			logger.log("failed"+"GetListOfOptionalBannededMessage wrong format"+delimiter, Level.WARNING);
			return "failed"+delimiter+"GetListOfOptionalBannededMessage wrong format"+delimiter;
		}
		else{
			answer = "CandidateBanndedList" +delimiter;
			String UserName = arr[0];//operate
			String SubForum = arr[1];
			ResultSet result = DB.getoptionalBanndedUsers(UserName,SubForum);
				try {
					while(result.next()){
						answer+= result.getString(1)+delimiter;
					}
				} catch (SQLException e) {
						
					e.printStackTrace();
				}
		return answer;
	}

	}
}





